#ifndef __AT_API_H
#define __AT_API_H

#include <stdbool.h>
#include <stdint.h>
#include <string.h>

typedef void (*mqtt_recv_callback)(char* topic, char *data,uint16_t data_len);

typedef enum
{
	AT_STATE_DEINITTED,
	AT_STATE_INITED,
	AT_STATE_CONNECTED,
	AT_STATE_DISCONNECTED,
}at_state_t;

typedef struct
{
	bool (*init)(void);
	bool (*deinit)(void);
	bool (*mqtt_connect)(char *server,uint16_t port,char *proKey, char *devName, char *devSecret);
	bool (*mqtt_disconnect)(void);
	bool (*mqtt_pub)(const char *topic, const char *message, uint16_t msg_len,uint32_t timeout);
	bool (*mqtt_sub)(const char *topic, int timeout);
	bool (*mqtt_unsub)(const char *topic);		
	bool (*mqtt_recv_register)(mqtt_recv_callback cb);
} at_dev_t;


bool at_dev_register(at_dev_t *dev);
bool at_dev_unregister(void);
bool at_mqtt_init(void);
bool at_mqtt_deinit(void);
bool at_mqtt_connect(char *server,uint16_t port,char *proKey, char *devName, char *devSecret);
bool at_mqtt_disconnect(void);
bool at_mqtt_pub(const char *topic, const char *message, uint16_t msg_len,uint32_t timeout);
bool at_mqtt_sub(const char *topic, int timeout);
bool at_mqtt_unsub(const char *topic);
bool at_mqtt_recv_register(mqtt_recv_callback cb);



#endif
